<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('任务记录')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <input name="taskId" th:value="${taskId}" type="hidden">
            </form>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('asset:astTask:edit')}]];
    var statusDatas = [[${@dict.getType('ast_renwu_status')}]];
    var prefix = ctx + "asset/astTask";

    $(function () {
        var options = {
            url: prefix + "/taskUserList",
            detailUrl: prefix + "/taskUserListDetail/{id}",
            modalName: "任务记录",
            columns: [{
                checkbox: true
            },
                {
                    field: 'userName',
                    title: '巡站人'
                },
                {
                    field: 'siteName',
                    title: '站点名称'
                },
                {
                    field: 'listStatus',
                    title: '任务状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    visible: editFlag == 'hidden' ? false : true,
                    title: '任务状态',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return statusTools(row);
                    }
                },
                {
                    field: 'listAloneDescribe',
                    title: '任务描述'
                },
                {
                    field: 'completeTime',
                    title: '完成时间'
                },
                {
                    field: 'deviceNoDescribe',
                    title: '异常设备描述'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-warning btn-xs" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.listId + '\')"><i class="fa fa-search"></i>任务图片</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function statusTools(row) {
        if (row.listStatus == 0) {
            return
            return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.listId + '\')"></i> ';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.listId + '\')"></i> ';
        }
    }

    /* 驳回 */
    function disable(listId) {
        $.modal.confirm("确认要驳回任务吗？", function() {
            $.operate.post(prefix + "/bohuiListStatus", { "listId": listId, "listStatus": 0 });
        })
    }

    /* 完成 */
    function enable(listId) {
        $.modal.confirm("确认任务已完成吗？", function() {
            $.operate.post(prefix + "/bohuiListStatus", { "listId": listId, "listStatus": 1 });
        })
    }

</script>
</body>
</html>